package com.huarui.purchaseOrder.action;

import java.util.HashMap;
import java.util.Map;

import org.ewaf.framework.action.BaseAction;

import com.huarui.params.Params;
import com.huarui.partner.service.PartnerService;
import com.huarui.purchaseOrder.enums.PurchaseFunctionEnum;
import com.huarui.purchaseOrder.model.PurOrSaleOrder;

/**
 * 
 * @author ycf
 *
 */
public class PurchaseNewAction extends BaseAction{

	public static final String MESS = "mess";
	private static final long serialVersionUID = 8636226415625424097L;
	
	private Map<String, Object> mesMap = new HashMap<String, Object>();
	
	private Integer companyId;
	
	private PartnerService partnerService;
	
	public Integer getCompanyId() {
		return companyId;
	}

	public void setCompanyId(Integer companyId) {
		this.companyId = companyId;
	}

	public Map<String, Object> getMesMap() {
		return mesMap;
	}

	public void setMesMap(Map<String, Object> mesMap) {
		this.mesMap = mesMap;
	}

	public void setPartnerService(PartnerService partnerService) {
		this.partnerService = partnerService;
	}

	/**
	 * 准备新建
	 * @return
	 */
	private String toCreate() {
		mesMap.put(Params.PUR_ORDER_STATUS_PARAM, PurOrSaleOrder.STATUS_INITIAL);
		mesMap.put(Params.PUR_LOADED_MESS_KEYS, PurchaseFunctionEnum.LOAD_BUTTONS_TOOL_BAR.getKey());
		return MESS;
	}
	
	public String onlineToCreate() {
		/*if(companyId != null) {
			boolean b = partnerService.checkPartner(companyId);
			if( b) {
				mesMap.put("result", "go_on");
				return toCreate();
			} else {
//				mesMap = partnerService.readyToCreatePartner(companyId);
				mesMap.put("result", "not_exist");
				return MESS;
			}
		} else {
			mesMap.put("result", "go_on");
			return toCreate();
		}*/
		return toCreate();
	}
	
	public String notOnlineToCreate() {
		return toCreate();
	}

}
